#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "test.h"

#include "trilogy/charset.h"
#include "trilogy/error.h"

#define ASSERT_CHARSET_ENCODING(ENCODING, CHARSET) ASSERT_EQ((ENCODING), trilogy_encoding_from_charset(CHARSET))

TEST test_encodings_match_charset()
{
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_NONE, TRILOGY_CHARSET_NONE);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_BIG5, TRILOGY_CHARSET_BIG5_CHINESE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_BIG5, TRILOGY_CHARSET_BIG5_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN2, TRILOGY_CHARSET_LATIN2_CZECH_CS);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN2, TRILOGY_CHARSET_LATIN2_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN2, TRILOGY_CHARSET_LATIN2_HUNGARIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN2, TRILOGY_CHARSET_LATIN2_CROATIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN2, TRILOGY_CHARSET_LATIN2_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_DEC8, TRILOGY_CHARSET_DEC8_SWEDISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_DEC8, TRILOGY_CHARSET_DEC8_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP850, TRILOGY_CHARSET_CP850_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP850, TRILOGY_CHARSET_CP850_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN1, TRILOGY_CHARSET_LATIN1_GERMAN1_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN1, TRILOGY_CHARSET_LATIN1_SWEDISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN1, TRILOGY_CHARSET_LATIN1_DANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN1, TRILOGY_CHARSET_LATIN1_GERMAN2_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN1, TRILOGY_CHARSET_LATIN1_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN1, TRILOGY_CHARSET_LATIN1_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN1, TRILOGY_CHARSET_LATIN1_GENERAL_CS);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN1, TRILOGY_CHARSET_LATIN1_SPANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_HP8, TRILOGY_CHARSET_HP8_ENGLISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_HP8, TRILOGY_CHARSET_HP8_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_KOI8R, TRILOGY_CHARSET_KOI8R_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_KOI8R, TRILOGY_CHARSET_KOI8R_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_SWE7, TRILOGY_CHARSET_SWE7_SWEDISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_SWE7, TRILOGY_CHARSET_SWE7_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_ASCII, TRILOGY_CHARSET_ASCII_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_ASCII, TRILOGY_CHARSET_ASCII_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UJIS, TRILOGY_CHARSET_UJIS_JAPANESE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UJIS, TRILOGY_CHARSET_UJIS_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_SJIS, TRILOGY_CHARSET_SJIS_JAPANESE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_SJIS, TRILOGY_CHARSET_SJIS_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1251, TRILOGY_CHARSET_CP1251_BULGARIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1251, TRILOGY_CHARSET_CP1251_UKRAINIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1251, TRILOGY_CHARSET_CP1251_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1251, TRILOGY_CHARSET_CP1251_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1251, TRILOGY_CHARSET_CP1251_GENERAL_CS);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_HEBREW, TRILOGY_CHARSET_HEBREW_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_HEBREW, TRILOGY_CHARSET_HEBREW_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_TIS620, TRILOGY_CHARSET_TIS620_THAI_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_TIS620, TRILOGY_CHARSET_TIS620_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_EUCKR, TRILOGY_CHARSET_EUCKR_KOREAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_EUCKR, TRILOGY_CHARSET_EUCKR_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN7, TRILOGY_CHARSET_LATIN7_ESTONIAN_CS);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN7, TRILOGY_CHARSET_LATIN7_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN7, TRILOGY_CHARSET_LATIN7_GENERAL_CS);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN7, TRILOGY_CHARSET_LATIN7_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_KOI8U, TRILOGY_CHARSET_KOI8U_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_KOI8U, TRILOGY_CHARSET_KOI8U_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_GB2312, TRILOGY_CHARSET_GB2312_CHINESE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_GB2312, TRILOGY_CHARSET_GB2312_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_GREEK, TRILOGY_CHARSET_GREEK_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_GREEK, TRILOGY_CHARSET_GREEK_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1250, TRILOGY_CHARSET_CP1250_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1250, TRILOGY_CHARSET_CP1250_CZECH_CS);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1250, TRILOGY_CHARSET_CP1250_CROATIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1250, TRILOGY_CHARSET_CP1250_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1250, TRILOGY_CHARSET_CP1250_POLISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_GBK, TRILOGY_CHARSET_GBK_CHINESE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_GBK, TRILOGY_CHARSET_GBK_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1257, TRILOGY_CHARSET_CP1257_LITHUANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1257, TRILOGY_CHARSET_CP1257_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1257, TRILOGY_CHARSET_CP1257_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN5, TRILOGY_CHARSET_LATIN5_TURKISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_LATIN5, TRILOGY_CHARSET_LATIN5_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_ARMSCII8, TRILOGY_CHARSET_ARMSCII8_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_ARMSCII8, TRILOGY_CHARSET_ARMSCII8_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_UNICODE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_ICELANDIC_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_LATVIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_ROMANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_SLOVENIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_POLISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_ESTONIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_SPANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_SWEDISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_TURKISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_CZECH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_DANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_LITHUANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_SLOVAK_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_SPANISH2_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_ROMAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_PERSIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_ESPERANTO_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_HUNGARIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_SINHALA_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8, TRILOGY_CHARSET_UTF8_GENERAL_MYSQL500_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_UNICODE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_ICELANDIC_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_LATVIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_ROMANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_SLOVENIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_POLISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_ESTONIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_SPANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_SWEDISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_TURKISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_CZECH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_DANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_LITHUANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_SLOVAK_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_SPANISH2_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_ROMAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_PERSIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_ESPERANTO_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_HUNGARIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_SINHALA_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UCS2, TRILOGY_CHARSET_UCS2_GENERAL_MYSQL500_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP866, TRILOGY_CHARSET_CP866_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP866, TRILOGY_CHARSET_CP866_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_KEYBCS2, TRILOGY_CHARSET_KEYBCS2_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_KEYBCS2, TRILOGY_CHARSET_KEYBCS2_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_MACCE, TRILOGY_CHARSET_MACCE_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_MACCE, TRILOGY_CHARSET_MACCE_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_MACROMAN, TRILOGY_CHARSET_MACROMAN_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_MACROMAN, TRILOGY_CHARSET_MACROMAN_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP852, TRILOGY_CHARSET_CP852_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP852, TRILOGY_CHARSET_CP852_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_UNICODE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_ICELANDIC_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_LATVIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_ROMANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_SLOVENIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_POLISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_ESTONIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_SPANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_SWEDISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_TURKISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_CZECH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_DANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_LITHUANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_SLOVAK_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_SPANISH2_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_ROMAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_PERSIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_ESPERANTO_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_HUNGARIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF8MB4, TRILOGY_CHARSET_UTF8MB4_SINHALA_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_UNICODE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_ICELANDIC_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_LATVIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_ROMANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_SLOVENIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_POLISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_ESTONIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_SPANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_SWEDISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_TURKISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_CZECH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_DANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_LITHUANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_SLOVAK_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_SPANISH2_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_ROMAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_PERSIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_ESPERANTO_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_HUNGARIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF16, TRILOGY_CHARSET_UTF16_SINHALA_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1256, TRILOGY_CHARSET_CP1256_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP1256, TRILOGY_CHARSET_CP1256_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_UNICODE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_ICELANDIC_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_LATVIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_ROMANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_SLOVENIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_POLISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_ESTONIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_SPANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_SWEDISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_TURKISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_CZECH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_DANISH_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_LITHUANIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_SLOVAK_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_SPANISH2_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_ROMAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_PERSIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_ESPERANTO_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_HUNGARIAN_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_UTF32, TRILOGY_CHARSET_UTF32_SINHALA_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_BINARY, TRILOGY_CHARSET_BINARY);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_GEOSTD8, TRILOGY_CHARSET_GEOSTD8_GENERAL_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_GEOSTD8, TRILOGY_CHARSET_GEOSTD8_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP932, TRILOGY_CHARSET_CP932_JAPANESE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_CP932, TRILOGY_CHARSET_CP932_BIN);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_EUCJPMS, TRILOGY_CHARSET_EUCJPMS_JAPANESE_CI);
    ASSERT_CHARSET_ENCODING(TRILOGY_ENCODING_EUCJPMS, TRILOGY_CHARSET_EUCJPMS_BIN);

    PASS();
}

int charset_test()
{
    RUN_TEST(test_encodings_match_charset);

    return 0;
}
